/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bionic.socialNet.command;

import com.bionic.socialNet.commandBeans.UserConnectionsBean;
import com.bionic.socialNet.entities.ProfileData;
import static com.bionic.socialNet.manager.AttributeNames.*;
import com.bionic.socialNet.manager.Config;
import java.io.IOException;
import java.util.ArrayList;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author Ann
 */
public class CommandFriends implements ICommand {

    @Override
    public String execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String page = Config.getInstance().getProperty(Config.FRIENDS);
        Integer userID = (Integer) request.getSession().getAttribute(USER_ID);
        UserConnectionsBean connectionsBean = new UserConnectionsBean();
        ArrayList<ProfileData> friendsProfiles = connectionsBean.getFriends(userID);
        request.setAttribute(FRIENDS_COLLECTION, friendsProfiles);
        return page;
    }
}
